import Utils from "@/utils/utils.js"
//登录
export function login(params) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `login`,
			method: "POST",
			data: params,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}
//游客注册
export function ykRegister(params) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/registermember`,
			method: "POST",
			data: params,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//商户注册
export function shRegister(params) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/registermerchant`,
			method: "POST",
			data: params,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

// 选择市场
export function getdeptList() {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `/mobile/getdeptList`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//获取短信
// export function getSmCode(phone) {
// 	return new Promise((resolve, reject) => {
// 		Utils.baseRequest({
// 			url: `mobile/sendVerificationCode/${phone}`,
// 			method: "POST",
// 		}).then(res => {
// 			resolve(res.data)
// 		}, err => {
// 			reject(err)
// 		})
// 	})
// }

//code获取openid
export function getWxOpenid(code) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/weixinLogin?code=${code}`,
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}

//openid登录
export function wxOpenidLogin(openid) {
	return new Promise((resolve, reject) => {
		Utils.baseRequest({
			url: `mobile/openidLogin/${openid}`,
			method: "POST",
		}).then(res => {
			resolve(res.data)
		}, err => {
			reject(err)
		})
	})
}